package iteratorPattern.demo;

import java.util.Iterator;
import java.util.List;

/**
 * @author： pang-yun
 * @date： 2021-12-09 19:38
 * 功能目的 ：用于
 */

public class InfoCollegeIterator implements Iterator {
    // 以list 方式存放
    List<Department> list;
    //索引
    int index = -1;

    public InfoCollegeIterator(List<Department> list) {
        this.list = list;
    }

    //
    @Override
    public boolean hasNext() {
        if (index >= list.size() - 1) {
            return false;
        } else {
            index++;
            return true;
        }

    }

    @Override
    public Object next() {
        return list.get(index);
    }

    @Override
    public void remove() {

    }
}
